package com.kt.controller;

import com.kt.domain.Category;
import com.kt.domain.Product;
import com.kt.service.imp.CategoryServiceImp;
import com.kt.service.imp.ProductServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delProduct.do")
public class DeleteProductServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        String pname = req.getParameter("pname");



        ProductServiceImp productServiceImp = new ProductServiceImp();
        int result = productServiceImp.delete(pname);
        if (result == 0) {
            resp.getWriter().write("商品下架失败");
            return;
        }
        resp.getWriter().write("商品下架成功");
    }
}
